package com.sdwz.commonutil.exception;

import com.sdwz.commonutil.ResultCodeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 自定义异常
 */
@Data
public class LibraryException extends RuntimeException {

    @ApiModelProperty(value = "异常状态码")
    private Integer code;

    public LibraryException() {
    }

    /**
     * 通过状态码和错误信息创建异常对象
     * @param code
     * @param message
     */
    public LibraryException(Integer code,String message){
        super(message);
        this.code = code;
    }

    /**
     * 通过枚举创建异常对象
     * @param resultCodeEnum
     */
    public LibraryException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }
}
